/**
 * @Author 韦建韩
 * @Date 2022/4/1
 */
package com.zczn.order_system.entity;

import java.math.BigDecimal;
import java.util.*;

public class ObjectArg implements CommonArg {
    Map<Object, Object> m = new HashMap<>();

    @Override
    public int size() {
        return m.size();
    }

    @Override
    public boolean isEmpty() {
        return m.isEmpty();
    }

    @Override
    public boolean containsKey(Object key) {
        return m.containsKey(key);
    }

    @Override
    public boolean containsValue(Object value) {
        return m.containsValue(value);
    }

    @Override
    public Object get(Object key) {
        return m.get(key);
    }
    public <T> T get(String key, Class<T> clazz) {
        Object value = this.m.get(key);
        if(Objects.isNull(value)){
            return null;
        }
        if(clazz.equals(BigDecimal.class))
            return (T)new BigDecimal(String.valueOf(value));
        return (T)value;
    }
    @Override
    public Object put(Object key, Object value) {
        return m.put(key, value);
    }

    @Override
    public Object remove(Object key) {
        return m.remove(key);
    }

    @Override
    public void putAll(Map m) {
        this.m.putAll(m);
    }

    @Override
    public void clear() {
        m.clear();
    }

    @Override
    public Set keySet() {
        return m.keySet();
    }

    @Override
    public Collection values() {
        return m.values();
    }

    @Override
    public Set<Entry<Object,Object>> entrySet() {
        return m.entrySet();
    }
}
